//
//  ThemeLabel.m
//  CloudWeibo
//
//  Created by CLOUD on 11/21/14.
//  Copyright (c) 2014 Cloud. All rights reserved.
//

#import "ThemeLabel.h"
#import "ThemeManager.h"

@implementation ThemeLabel

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

- (id)initWithColor:(NSString *) colorName
{
    self = [self init];
    if (self) {
        self.colorName = colorName;
    }
    return self;
}

- (id) init
{
    self = [super init];
    if (self) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(themeNotification) name:kThemeDidChangeNofication object:nil];
    }
    return self;
}

- (void)setColorName:(NSString *)colorName
{
    if (_colorName != colorName) {
        [_colorName release];
        _colorName = [colorName copy];
    }
    [self loadColor];
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super dealloc];
}

- (void)themeNotification {
    [self loadColor];
}

- (void)loadColor {
    UIColor *color = [[ThemeManager shareInstance] getThemeColor:self.colorName];
    self.textColor = color;
}
@end
